package com.xinchuang.controller.targetSystem.damage;

import com.xinchuang.comment.R;
import com.xinchuang.common.Result;
import com.xinchuang.common.ResultUtil;
import com.xinchuang.dto.DeleteDto;
import com.xinchuang.entity.targetSystem.damage.TMissileGuide;
import com.xinchuang.service.targetSystem.damage.TMissileGuideService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author lvjie
 * @program t_missile_guide
 * @description 制导方式
 * @date 2024/05/15
 */
@RestController
@RequestMapping("/tMissileGuide")
@Api(value = "制导方式", tags = "制导方式")
public class TMissileGuideController {

    @Autowired
    private TMissileGuideService tMissileGuideService;

    /**
     * 添加制导方式，导弹制导方式表（t_missile_guide）
     * @param tMissileGuide
     * @return
     */
    @PostMapping("/addAndUpdateMissileGuide")
    public R addMissileGuide(@RequestBody TMissileGuide tMissileGuide) {
        return tMissileGuideService.addAndUpdateMissileGuide(tMissileGuide);
    }

    /**
     * 删除制导方式，导弹制导方式表（t_missile_guide）
     * @return
     */
    @DeleteMapping("/deleteMissileGuide")
    public Result deleteMissileGuide(@RequestParam(value = "deleteStatus") boolean deleteStatus,
                                     @RequestParam(value = "ids[]") String id) {
        tMissileGuideService.deleteMissileGuide(id);
        return ResultUtil.success(null, "删除成功");
    }

    /**
     * 删除战斗部
     * @return
     */
    @DeleteMapping("/listMissileGuide")
    public R deleteWarheadGuide(@RequestParam(value = "deleteStatus") boolean deleteStatus,
                                @RequestParam(value = "ids[]") String id) {
        tMissileGuideService.deleteWarheadGuide(id, deleteStatus);
        return R.success("删除成功");
    }

    /**
     * 分页查询制导方式，导弹制导方式表（t_missile_guide）
     * @param pageSize 页包含数据条数
     * @param pageNum 第几页
     * @param guideMeans 制导手段
     * @param guideType 制导方式：1是中制导，2是末制导
     * @return
     */
    @GetMapping ("/listMissileGuide")
    public R listMissileGuide(@RequestParam Integer pageSize,
                              @RequestParam Integer pageNum,
                              @RequestParam String missileId,
                              @RequestParam(value = "guideMeans",required = false) String guideMeans,
                              @RequestParam(value = "guideType",required = false) String guideType) {
        Map<String, Object> tMissileGuides = tMissileGuideService.listMissileGuide(pageSize,pageNum,missileId,guideMeans,guideType);
        return R.data(tMissileGuides);
    }
}
